<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="utf-8" />
		<title>展示</title>
		<link rel="stylesheet" href="css/bootstrap.min.css" />
        <link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css"/>
		<style>
            #message, .message {
                position: fixed;
                top: 100px;
                left: 47%;
                width: 220px;
                margin-left: -100px;
                border-width:0;
                border-radius: 0.6em;
                color:#ffffff;
                background-color: #2c2c2c ;
                box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
                padding: 10px;
                text-align:center;
                opacity: 1;
                z-index:1500;
                -webkit-transition: opacity 1s ease-out; /* Saf3.2+, Chrome */
                -moz-transition: opacity 1s ease-out; /* FF4+ */
                -ms-transition: opacity 1s ease-out; /* IE10? */
                -o-transition: opacity 1s ease-out; /* Opera 10.5+ */
                transition: opacity 1s ease-out;
            }
			
			.float {
				float: right;
			}
		</style>
	</head>

	<body>
    <div id="message" style="display: none;"></div>
		<nav class="navbar navbar-inverse">
			<div class="container-fluid">
				<!-- Brand and toggle get grouped for better mobile display -->
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
					<a class="navbar-brand" href="#">旅居</a>
				</div>

				<!-- Collect the nav links, forms, and other content for toggling -->
				<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
					<ul class="nav navbar-nav">
						<li class="active">
							<a href="#">信息录入 <span class="sr-only">(current)</span></a>
						</li>
						<li>
							<a href="http://112.124.107.209:8082/work" id="jobDetail" style="display: none;">工作汇报 <span class="sr-only">(current)</span></a>
						</li>
					</ul>
					<ul class="nav navbar-nav navbar-right" style="padding-top: 15px;">
						<li>
							<label style="color: whitesmoke;" id="nickName"></label>
						</li>
						<li style="padding-left: 15px;">
							<button class="btn btn-danger btn-sm" style="padding-top: 2px;" onclick="logout()">logout</button>
						</li>
						<li style="padding-left: 15px;">
							<button class="btn btn-primary btn-sm" style="padding-top: 2px;" onclick="downloadExcelAll()">导出全部</button>
						</li>
						<li style="padding-left: 15px;">
							<button class="btn btn-primary btn-sm" id="userOutPut" style="padding-top: 2px;display: none" onclick="downloadByUser()">按组员导出</button>
						</li>
					</ul>
				</div>
				<!-- /.navbar-collapse -->
			</div>
			<!-- /.container-fluid -->
		</nav>

		<form class="form-inline" action="http://112.124.107.209:8082/search" method="get">
			<div class="form-group">
				<label for="phoneNumber">手机号</label>
				<input type="text" class="form-control" id="phoneNumber" placeholder="客人手机号">
			</div>
			<div class="form-group">
				<label for="consumerName">客人姓名</label>
				<input type="text" class="form-control" id="consumerName" placeholder="客人姓名">
			</div>
			<div class="form-group" style="display: none" id="userSearch">
				<label for="user">员工</label>
				<input type="text" class="form-control" id="user" placeholder="员工">
			</div>
			<button type="submit" class="btn btn-info" onclick="search();return false;">搜索</button>
			<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">新增</button>
			<button type="button" onclick="reloadPage()" class="btn btn-info">刷新</button>
			<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#openWorkInfoModal">工作汇报</button>
		</form>

		<table class="table table-hover">
			<thead>
				<tr>
					<th>序号</th>
					<th>客户姓名</th>
					<th>电话号码</th>
					<th>所在地</th>
					<th>预算</th>
					<th>客户等级</th>
					<th>联系状态</th>
					<th>客户来源</th>
					<th>客户微信</th>
					<th>置业顾问</th>
					<th>创建日期</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody id="tableBody">

			</tbody>
		</table>

		<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
						<h4 class="modal-title" id="myModalLabel">新增客户</h4>
					</div>
					<form action="http://112.124.107.209:8082/customer" method="post">
						<div class="modal-body">
							<div class="form-group">
								<label for="CustomerName">顾客姓名</label>
								<input type="text" class="form-control" name="customerName" id="CustomerName" placeholder="姓名">
							</div>
							<div class="form-group">
								<label for="customerNumber">手机号</label>
								<input type="text" class="form-control" id="customerNumber" name="customerNumber" placeholder="手机号">
							</div>
							<div class="form-group">
								<label for="area">所在地</label>
								<input type="text" class="form-control" id="area" name="customerArea" placeholder="所在地">
							</div>
							<div class="form-group">
								<label for="budget">预算</label>
								<input type="text"  class="form-control" id="budget" name="budget" placeholder="预算(以万为单位)">
							</div>
							<div class="form-group form-inline">
								<label for="customerLevel">客户等级</label>
								<select name="customerLevel" class="form-control" id="customerLevel">
									<option value="A">A</option>
									<option value="B" selected="selected">B</option>
									<option value="C">C</option>
								</select>
								<div class="float">
									<label for="customerSource">客户来源</label>
									<select name="customerSource" class="form-control" id="customerSource">
										<option value="分配电话">分配电话</option>
										<option value="官网留言" selected="selected">官网留言</option>
										<option value="微信公众号">微信公众号</option>
										<option value="线下">线下</option>
									</select>
								</div>
							</div>
							<div class="form-group form-inline">
								<label for="customerContact">联系情况</label>
								<select name="customerContact" class="form-control" id="customerContact">
									<option value="接通" selected="selected">接通</option>
									<option value="未接通">未接通</option>
									<option value="挂断">挂断</option>
								</select>
								<div class="float">
									<label for="customerWechat">客人微信</label>
									<input type="text" class="form-control" name="customerWechat" id="customerWechat" placeholder="客人微信">
								</div>
							</div>

						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<button type="submit" class="btn btn-primary">提交</button>
						</div>
					</form>
				</div>
				<!-- /.modal-content -->
			</div>
		</div>

        <!-- 模态框（Modal） -->
        <div class="modal fade" id="cusInfo" tabindex="-1" role="dialog" aria-labelledby="infoLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
                        </button>
                        <h4 class="modal-title" id="infoLabel">
                            通话详情<button class="btn btn-info btn-sm" id="addMessage" onclick="addMessage()" style="float: right;margin-right: 20px;">新增</button>
                        </h4>
                    </div>

                    <div class="modal-body">
                        <div class="well">

                        </div>
                        <div  id="infoBody">

                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">
                            关闭
                        </button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="deleteInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="deleteInfoLabel">删除联系人</h4>
                </div>
                <div class="modal-body">您确定要删除该联系人吗？请谨慎操作</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-info" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-danger" onclick="delInfo()">删除</button><label style="display: none" id="delId"></label>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

	<!-- 模态框（Modal） -->
	<div class="modal fade" id="openWorkInfoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="openWorkInfoModalLabel">新增工作汇报</h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<label for="budget">工作汇报内容</label>
						<textarea rows="6" type="text"  class="form-control" id="workContent" name="content" placeholder="工作内容"></textarea>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-info" onclick="submitWork()">提交</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>

	<!-- 模态框（Modal） -->
	<div class="modal fade" id="download" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="downloadExcel">导出制定员工报表</h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<label for="userNickName">员工姓名</label>
						<input type="text"  class="form-control" id="userNickName" name="customerNumber" placeholder="员工姓名"><br/>
						<span id="downloadError" style="color: red"></span>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-info" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-info" onclick="downloadExcelByUser()">导出</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="updateInfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="updateInfoLabel">修改客户</h4>
                </div>
                <form action="#" method="post">
                    <div class="modal-body">
                        <div class="form-group">
                            <label for="CustomerName">顾客姓名</label>
                            <input type="text" class="form-control" name="customerName" id="lastCustomerName" placeholder="姓名">
                        </div>
                        <div class="form-group">
                            <label for="customerNumber">手机号</label>
                            <input type="text" class="form-control" id="lastcustomerNumber" name="customerNumber" placeholder="手机号">
                        </div>
                        <div class="form-group">
                            <label for="area">所在地</label>
                            <input type="text" class="form-control" id="laseArea" name="customerArea" placeholder="所在地">
                        </div>
                        <div class="form-group">
                            <label for="budget">预算</label>
                            <input type="text"  class="form-control" id="lastBudget" name="budget" placeholder="预算(以万为单位)">
                        </div>
                        <div class="form-group form-inline">
                            <label for="customerLevel">客户等级</label>
                            <select name="customerLevel" class="form-control" id="lastCustomerLevel">
                                <option value="A">A</option>
                                <option value="B" selected="selected">B</option>
                                <option value="C">C</option>
                            </select>
                            <div class="float">
                                <label for="customerSource">客户来源</label>
                                <select name="customerSource" class="form-control" id="lastCustomerSource">
                                    <option value="分配电话">分配电话</option>
                                    <option value="官网留言" selected="selected">官网留言</option>
                                    <option value="微信公众号">微信公众号</option>
                                    <option value="线下">线下</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group form-inline">
                            <label for="customerContact">联系情况</label>
                            <select name="customerContact" class="form-control" id="lastCustomerContact">
                                <option value="接通" selected="selected">接通</option>
                                <option value="未接通">未接通</option>
                                <option value="挂断">挂断</option>
                            </select>
                            <div class="float">
                                <label for="customerWechat">客人微信</label>
                                <input type="text" class="form-control" name="customerWechat" id="lastCustomerWechat" placeholder="客人微信">
                            </div>
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" id="editInfo" class="btn btn-primary">提交</button>
                    </div>
                </form>
            </div>
            <!-- /.modal-content -->
        </div>
    </div>



		<nav style="text-align: center">
			<ul class="pagination" id="page"></ul>
		</nav>
	<div style="line-height: 20px;text-align: center">
		<p>Copyright &copy; lory 2018</p>
	</div>
			<!-- /.modal -->
			<script type="text/javascript" src="js/jquery.min.js"></script>
			<script type="text/javascript" src="js/bootstrap.min.js"></script>
			<script type="text/javascript" src="js/main.js"></script>
			<script type="text/javascript" src="js/bootstrap-paginator.js"></script>
            <script type="text/javascript" src="js/bootstrap-datetimepicker.min.js"></script>
            <script type="text/javascript" src="js/bootstrap-datepicker.zh-CN.js"></script>
		<script type="text/javascript">
			$(function () {
                $.ajax({
                    //几个参数需要注意一下
                    type: "GET",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "http://112.124.107.209:8082/session",//url
                    success: function (result) {
						$("#nickName").text(result.data.nickname);
						var role = result.data.role;
						if (role == 'user'){
							$("#userSearch").css("display",'');
							$("#userOutPut").css("display",'');
							$("#jobDetail").css("display", '');
						}
                    }
                });
                $.ajax({
                    //几个参数需要注意一下
                    type: "GET",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "http://112.124.107.209:8082/customer/1" ,//url
                    success: function (result) {
						var content = createHtml(result.data.list);
                        $("#tableBody").html(content);
                        /*$("body").on('click', "#tableBody tr td:last button:first", function(){
                            var id = $(this).parent().parent().find('td:first').html();

                        });*/
                        var options = {
                            currentPage: result.data.pageNum,
                            totalPages: result.data.lastPage,
                            numberOfPages: result.data.pages,
                            bootstrapMajorVersion:3,
                            itemTexts: function (type, page, current) {
                                switch (type) {
                                    case "first":
                                        return "首页";
                                    case "prev":
                                        return "上一页";
                                    case "next":
                                        return "下一页";
                                    case "last":
                                        return "末页";
                                    case "page":
                                        return page;
                                }
                            },onPageClicked: function(event, originalEvent, type, page){
                                $.ajax({
                                    //几个参数需要注意一下
                                    type: "GET",//方法类型
                                    dataType: "json",//预期服务器返回的数据类型
                                    url: "http://112.124.107.209:8082/customer/"+page,//url
									success: function (result) {
                                        $("#tableBody").children().remove();
										var content = createHtml(result.data.list);
                                        $("#tableBody").html(content);
                                    }
								});
                            }

                        };
                        $('#page').bootstrapPaginator(options);
                    },
                    error : function() {
                        alert("异常！");
                    }
                });

            });
			function createHtml(data) {
                var content = '';
                for (var i = 0; i< data.length;i++){
                    content += "<tr><td>"+data[i].id+"</td><td>"+data[i].customerName+
                        "</td><td>"+data[i].customerNumber+"</td><td>"+data[i].customerArea+
                        "</td><td>"+data[i].budget+"<span style='font-weight: bold'>万</span></td><td>"+data[i].customerLevel+
                        "</td><td>"+data[i].customerContact+"</td><td>"+data[i].customerSource+"</td><td>"+data[i].customerWechat+"</td><td>"+data[i].nickname+"</td><td>"+new Date(data[i].createTime).toLocaleDateString()+
                        "</td><td><button onclick='detailContact(this)' class='cusInfo btn btn-info btn-sm' data-toggle='modal'>查看详情</button><button class='btn btn-danger btn-sm' onclick='deleteInfo(this)'>删除</button>" +
                        "<button class='btn btn-primary btn-sm' onclick='updateInfo(this)'>修改</button></td></tr>";
                }
                return content;
            }
            function search() {
				var customerNumber = $("#phoneNumber").val();
				var customerName = $("#consumerName").val();
				var nickname = $("#user").val();
				var dis = $("#userSearch").css("display");
				if (dis == 'inline-block') {
                    if (customerNumber == "" && customerName == "" && nickname == "") {
                        return false;
                    }else {
                        searchAjax(customerNumber,customerName,nickname);
					}
                }else{
                    if (customerNumber == "" && customerName == ""){
                        return false;
                    }else {
                        searchAjax(customerNumber, customerName, null);
					}
				}



            }
			function searchAjax(customerNumber,customerName, nickname) {
                $.ajax({
                    //几个参数需要注意一下
                    type: "GET",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "http://112.124.107.209:8082/customer/search/1?customerNumber="+customerNumber+"&customerName="+customerName+"&nickname="+nickname,//url
                    success: function (result) {
                        var content = createHtml(result.data.list);
                        $("#tableBody").html(content);
                        var options = {
                            currentPage: result.data.pageNum,
                            totalPages: result.data.lastPage,
                            numberOfPages: result.data.pages,
                            bootstrapMajorVersion:3,
                            itemTexts: function (type, page, current) {
                                switch (type) {
                                    case "first":
                                        return "首页";
                                    case "prev":
                                        return "上一页";
                                    case "next":
                                        return "下一页";
                                    case "last":
                                        return "末页";
                                    case "page":
                                        return page;
                                }
                            },onPageClicked: function(event, originalEvent, type, page){
                                $.ajax({
                                    //几个参数需要注意一下
                                    type: "GET",//方法类型
                                    dataType: "json",//预期服务器返回的数据类型
                                    url: "http://112.124.107.209:8082/customer/search/"+page+"?customerNumber="+customerNumber+"&customerName="+customerName,//url
                                    success: function (result) {
                                        $("#tableBody").children().remove();
                                        var content = createHtml(result.data.list);
                                        $("#tableBody").html(content);
                                    }
                                });
                            }

                        };
                        $('#page').bootstrapPaginator(options);
                    },
                    error : function() {
                        alert("异常！");
                    }
                });
            }
            
            function addMessage() {
                var content = "<form action='#'><div class='input-append date form_datetime form-group'> " +
                    "<label for='contactTime' name='contactTime'>联系时间</label><input size='16' type='text' value='' placeholder='请输入开始时间' class='form-control' name='contactTime' id='start' readonly> " +
                    "<span class='add-on'><i class='icon-th'></i></span> </div><label>联系内容</label><textarea class='form-control' rows='3' id='infoContent' name='content' placeholder='内容'></textarea>" +
                    "<button type='button' class='btn btn-primary' style='margin-top: 5px;' onclick='submitMessage()'>提交</button></form>";
                $("#infoBody").html(content);

                $(".form_datetime").datepicker({
                    format: "yyyy-mm-dd",
                    language:"zh-CN",
                    minView: "month",
                    autoclose: true,
                    todayBtn: false,
                    startDate: "2013-02-14 10:00",
                    minuteStep: 10
                });
            }
            function submitMessage() {
			    var contactTime = $("#start").val();
			    var content = $("#infoContent").val();
			    var id = $("#labelId").text();
			    var message = {
                    contactTime: contactTime,
                    content: content
                };
                $.ajax({
                    type: 'POST',
                    contentType: 'application/json;charset=utf-8',
                    dataType: "json",//预期服务器返回的数据类型
                    url: "http://112.124.107.209:8082/customer/info/add/"+id,//url
                    data: JSON.stringify(message),
                    success: function (result) {
                        msg(result.msg);
                        $("#cusInfo").modal('hide');
                    }
                });
            }

            var t;
			var tt;
            //提示框
            function msg(text) {
                if(g('checkError')!=null){
                    hide('checkError');
                }
                if (text == '') {
                    return;
                }
                var msgDiv = g('message');
                msgDiv.innerHTML=text;
                msgDiv.style.opacity=1;
                msgDiv.style.filter="alpha(opacity=100)";
                show('message');
                clearTimeout(t);
                clearTimeout(tt);
                tt=setTimeout("test('message')",3000);
            }
            function test(id){
                g(id).style.opacity= 0;
                g(id).style.filter="alpha(opacity=0)";
                t=setTimeout("hide('message')",1000);
            }
            function g(id) {
                return document.getElementById(id);
            }
            function hide(id) {
                g(id).style.display = 'none';
            }
            function show(id) {
                g(id).style.display = 'block';
            }


            function deleteInfo(ele) {
                $("#delId").text('');
                var id = $(ele).parent().parent().find('td:first').html();
                $("#deleteInfo").modal('show');
                $("#delId").text(id);
            }
            
            function delInfo() {
                var id = $("#delId").text();
                $.ajax({
                    type: "DELETE",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "http://112.124.107.209:8082/customer/"+id,//url
                    success: function (result) {
                        msg(result.msg);
                        $("#deleteInfo").modal('hide');
                        window.location.reload();
                    }
                });
            }
			function logout() {
                $.ajax({
                    type: "GET",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "http://112.124.107.209:8082/oa/logout",//url
                    success: function (result) {
                        console.log(result);
                        if (result.code == 200){
                            window.location.href = "http://112.124.107.209:8082";
						}
                    }
                });
            }

            function downloadExcelAll() {
                var dFrame=$("<iframe>");
                dFrame.attr("style","display: none");
                dFrame.attr("name","downloadFrame");
                dFrame.attr("src","http://112.124.107.209:8082/excel/downloadAll");
                $("body").append(dFrame);
            }
            
            function downloadByUser() {
                $("#downloadError").text("");
                $("#download").modal('show');

            }
            function downloadExcelByUser() {
				var userNickname = $("#userNickName").val();
				if (userNickname == null || userNickname == ''){
				    $("#downloadError").text("员工名不能为空");
                    $("#download").modal('show');
				}else {
					var dFrame=$("<iframe>");
					dFrame.attr("style","display: none");
					dFrame.attr("name","downloadFrame");
					dFrame.attr("src","http://112.124.107.209:8082/excel/downloadByUser?nickname="+userNickname);
					$("body").append(dFrame);
                    $("#download").modal('hide');
				}
            }

            function reloadPage() {
				window.location.reload();
            }

            function detailContact(ele) {
                var id = $(ele).parent().parent().find('td:first').html();
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: "http://112.124.107.209:8082/customer/info/"+id,
                    success: function (result) {
                        var content = '';
                        if (result.data == null || result.data.length == 0){
                            content = "<label id='labelId' style='display: none'>"+id+"</label><br/><p>无内容</p>";
                        }
                        for (var j = 0; j< result.data.length; j++){
                            content += "<label id='labelId' style='display: none'>"+id+"</label><p>"+new Date(result.data[j].contactTime).toLocaleDateString()+"<br/>"+
                                result.data[j].content+"<br />"+"---------------------------</p>";
                        }
                        $(".well").html(content);
                        $("#infoBody").html('');
                        $("#cusInfo").modal('show');
                    }
                });
            }
            
            function submitWork() {
				var content = $("#workContent").val();
				if (content == null || content == ''){
				    msg("汇报内容不能为空");
				    return;
				}else {
				    var content = content;
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: "http://112.124.107.209:8082/workInfo/add?content="+content,
                        success: function (result) {
                            if (result.code == 200) {
                                msg(result.msg);
                                $("#openWorkInfoModal").modal("hide");
                            } else {
                                msg(result.msg);
                            }
                        }
                    })
				}
            }

            function updateInfo(ele) {
                var id = $(ele).parent().parent().find("td:eq(0)").html();
                var name = $(ele).parent().parent().find("td:eq(1)").html();
                var phone = $(ele).parent().parent().find("td:eq(2)").html();
                var aera = $(ele).parent().parent().find("td:eq(3)").html();
                var budget = $(ele).parent().parent().find("td:eq(4)").text();
                budget = budget.substring(0,budget.length-1);
                var level = $(ele).parent().parent().find("td:eq(5)").html();
                var status = $(ele).parent().parent().find("td:eq(6)").html();
                var source = $(ele).parent().parent().find("td:eq(7)").html();
                var wechat = $(ele).parent().parent().find("td:eq(8)").html();
                $("#lastCustomerName").val(name);
                $("#lastcustomerNumber").val(phone);
                $("#laseArea").val(aera);
                $("#lastBudget").val(budget);
                $("#lastCustomerLevel").val(level);
                $("#lastCustomerSource").val(source);
                $("#lastCustomerContact").val(status);
                $("#lastCustomerWechat").val(wechat);
                $("#updateInfo").modal('show');
                $("#editInfo").click(function () {
                    var customerName = $("#lastCustomerName").val();
                    var customerNumber = $("#lastcustomerNumber").val();
                    var customerArea = $("#laseArea").val();
                    var budget = $("#lastBudget").val();
                    var customerLevel = $("#lastCustomerLevel").val();
                    var customerSource = $("#lastCustomerSource").val();
                    var customerContact = $("#lastCustomerContact").val();
                    var customerWechat = $("#lastCustomerWechat").val();
                    if (customerName == ""){
                        msg("姓名不能为空");
                        return;
                    }
                    if (customerNumber == ""){
                        msg("手机号不能为空");
                        return;
                    }
                    if(budget != ''){
                        if (isNaN(budget)){
                            msg("金额必须为数字");
                            return;
                        }
                    }

                    if (customerArea == ""){
                        msg("所在地不能为空");
                        return;
                    }
                    var info = {
                        id: id,
                        customerName:customerName,
                        customerNumber:customerNumber,
                        customerArea:customerArea,
                        budget:budget,
                        customerLevel:customerLevel,
                        customerSource:customerSource,
                        customerContact:customerContact,
                        customerWechat:customerWechat
                    }
                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        contentType: 'application/json;charset=utf-8',
                        url: "http://112.124.107.209:8082/customer/edit",//url
                        data:JSON.stringify(info),
                        success: function (result) {
                            if (result.code == 200){
                                msg(result.msg);
                                $("#updateInfo").modal('hide');
                                window.location.reload();
                            }else {
                                msg("保存失败");
                            }
                        }
                    });

                });
            }

		</script>
	</body>

</html>